home *** CD-ROM | disk | FTP | other *** search
/ Amiga Mag HDD Backup / Amiga Mag HDD Backup.zip / Amiga Mag HDD Backup / Alexander.img.bin / Alexander.img / 10.4 material / Article.txt < prev   
Text File  |  1983-05-04  |  9KB  |  171 lines

  1. Revitalizing the X-Specs 3D Stereoscopic Glasses
  2.  
  3. Randy Finch
  4.  
  5.  
  6.  
  7.     Many years ago a very interesting, very powerful, yet very
  8. inexpensive (about $100) piece of hardware became available for
  9. the Amiga computer.  It consisted of a small black box that
  10. plugged into the second mouse port and had two small holes that
  11. allowed two sets of dark space age-like glasses to be plugged in. 
  12. One set of glasses was included in the package.  The glasses
  13. attached to the human head via a headband (see Figure 1).  This
  14. made it very nice for eyeglass wearers like me because they fit
  15. comfortably over eyeglasses.  The dark glasses consisted of LCD
  16. lenses that could be darkened and lightened very quickly via
  17. software and looked like a low-tech version of the virtual
  18. reality glasses that are in vogue today.  By allowing the left
  19. eye to see only a left-eye perspective of a scene and the right
  20. to see only a right-eye perspective via fast image switching, an
  21. illusion of 3D could be had from a single Amiga display.  This
  22. piece of hardware was distributed by Haitex Resources, Inc. and
  23. was known as the X-Specs 3D Stereoscopic Glasses.
  24.     I first saw this amazing piece of hardware at the 1988
  25. AmiExpo in Chicago.  I sat down, placed the glasses over my head,
  26. and proceeded to view three-dimensional molecules and play a
  27. quick game of Space Spuds.  Both of these programs were included
  28. with the glasses along with some demonstration and utility
  29. programs.  It was a great bargain.  Being a programmer, I was
  30. also interested to hear that a shared library was being written
  31. so that any programmer could easily tap into the power of the
  32. X-Specs glasses.  I purchased the glasses shortly after the show
  33. and never regretted it.
  34.     Although quite a number of software producers began to
  35. support the X-Specs glasses, they never seemed to gain the
  36. popularity I thought they deserved.  For some time the glasses
  37. have been hard to find, but now I cannot find any dealer that
  38. carries them or even knows of anyone who does.  However, I would
  39. guess that a reasonably priced set of used glasses can still be
  40. found.  (For your information, I am not selling mine.)  To
  41. illustrate just how little software has been written for the
  42. glasses, I searched the Gold Fish CD-ROM, which contains the
  43. first 1000 Fred Fish disks, for the word X-Specs and only turned
  44. up two references: LanderGame and RaiderGame.  These are 3D games
  45. for the X-Specs glasses.  Both are on Fish Disk 544.
  46.     Like the X-Specs glasses, it seems that the interest in 3D
  47. technology has always been an up and down phenomenon.  In the
  48. early part of the century, the old wooden stereoscopes that
  49. consisted of two lenses that allowed each eye to see only one of
  50. two images on a black & white postcard became popular.  Their
  51. popularity faded only to be revived years later when the
  52. ViewMaster became available.  Although the ViewMaster is still
  53. available, it does not seem to be as popular as it was when I was
  54. a kid.  Of course, 3D movies were the craze back in the 50's. 
  55. Now, 3D movies are rarely, if ever, made.  I believe that it has
  56. something to do with having to wear funny glasses or look through
  57. some kind of binocular device.  When 3D imaging becomes available
  58. for direct viewing just as we currently view a movie or a TV or a
  59. computer monitor, it may become popular and stay popular. 
  60. Perhaps a more advanced kind of holography will provide the
  61. technology.
  62.  
  63. Programming the X-Specs 3D Glasses
  64.     As I was told at AmiExpo, a shared library was soon released
  65. so that even I could write programs for the X-Specs glasses.  At
  66. the time, I was working on a 3D function plotting program that
  67. was a perfect candidate for adding X-Specs support.  The library
  68. is named xspecs.library.  Version 1.2 of this library consists of
  69. 36 functions.  Although I program in C, the library can be used
  70. by any language that supports the standard Amiga shared
  71. libraries.  Table 1 shows the names and brief descriptions of the
  72. functions available in the library.  Several are available for
  73. allocating and deallocating Rastport and Viewport data structures
  74. for regular views, double-buffered views, and overscan views. 
  75. Pen colors, the pen number, and the drawing mode can all be set. 
  76. Lines, polygons, text, and even sprites can be drawn in three
  77. dimensional space.
  78.     Unfortunately, the compressed files that I downloaded
  79. containing the library did not have a C header file containing
  80. the #pragma statements and function prototypes needed by my
  81. program.  However, the documentation had enough information in it
  82. for me to create a file definition (.fd) file (Listing 1).  I
  83. used the fd2pragma program that was included with my SAS/C
  84. compiler to convert this .fd file to a C header file containing
  85. the #pragma statements.  I then appended function prototypes. 
  86. This file is shown in Listing 2.  With this completed, I was
  87. ready to add X-Specs support to my program.
  88.     Listing 3 shows excerpts from my three dimensional function
  89. plotting program.  An earlier version of this program that does
  90. not have X-Specs support can be found on Fish Disk 440.  It is
  91. named 3DPlot.  The excerpts contain some code that I will not
  92. discuss since it is not relevant to the current discussion.  I
  93. only left this code in the listing to provide a context for the
  94. X-Specs function calls.
  95.     Notice first that the header file XSpecsLib.h is #included
  96. near the beginning to make the #pragmas and function prototypes
  97. available.  Also, an external Library structure pointer (it is
  98. opened in a different file) named XSpecsBase is declared.
  99.     When the user requests that an X-Specs plot be rendered, the
  100. DrawGraph function is called with a global variable, plottype,
  101. set equal to PLOTXSPECS, which is #defined in another header
  102. file.  A message port is declared along with an array containing
  103. the 32 colors for the X-Specs screen.  The RastPort and ViewPort
  104. structures for the X-Specs display are allocated with the
  105. XSpecsAllocView function.  The NULL parameter indicates that a
  106. 32-color 320x200 screen should be created.  Other screen
  107. resolutions can be allocated by passing a different parameter. 
  108. The screen is displayed on the monitor with the XSpecsOn
  109. function, which returns the message port of the display.  The
  110. MOUSEBUTTONS parameters indicates that only mouse button
  111. messages should be sent to this port.  Next, the palette is
  112. filled by calling the XSpecsLoadRGB4 function.
  113.     Following the code further down, you will find a lot of
  114. calculations being made to set up for the actual plot. 
  115. Eventually, another program function, CalcAndPlot3, is called. 
  116. This function is shown near the beginning of Listing 3.  It does
  117. the grunt work of calculating the three dimensional coordinates
  118. for the plot on the X-Specs display.  The plot consists of a
  119. patchwork of four-sided polygons.  After calculating the
  120. coordinates of the four corners of a polygon and calculating the
  121. color to use for it, three xspecs.library functions are called to
  122. accomplish the task.  First, XSpecsSetAPen is called to set the
  123. appropriate color, XSpecsMove is called to move the pen to the
  124. appropriate starting point in three dimensional space, and
  125. XSpecsDraw is called three times to draw three sides of the four-
  126. sided polygon.  The fourth side is drawn when an adjoining four-
  127. sided polygon is drawn.  This saves a bit of plot time because
  128. the adjoining sides do not have to be drawn twice.
  129.     Near the end of the DrawGraph function is a WaitPort system
  130. function call.  This call waits for a message to be received at
  131. win's message port before closing the X-Specs display.  The
  132. Window pointer named win points to a window created by the
  133. 3DPlot program.  Why am I waiting for a message at this port
  134. rather than the one for the X-Specs display?  I don't know.  It
  135. turns out if you use the following statement,
  136.  
  137.     WaitPort(uport);
  138.  
  139. where uport is the message port returned by the XSpecsOn
  140. function, a message will be received properly for a press of the
  141. right mouse button, but the program will essentially freeze when
  142. the left mouse button is pressed.  By using the statement,
  143.  
  144.     WaitPort(win->UserPort);
  145.  
  146. where win->UserPort is the message port of another window in the
  147. 3DPlot program not related to the X-Specs display, the left mouse
  148. button can be pressed without freezing the program.  However, it
  149. takes a right button press after the left button press to cause a
  150. message to be received at win->UserPort.  I have not yet
  151. determined why this works this way.  If anyone has any ideas,
  152. please let me know.
  153.     Finally, the XSpecsOff function is called to close the X-
  154. Specs display, and XSpecsFreeView is called to deallocate the
  155. RastPort and ViewPort structures for the display.
  156.  
  157. In Closing
  158.     The X-Specs 3D glasses can be programmed easily using
  159. xspecs.library.  The latest version of this library of which I am
  160. aware is 1.2.  I have tried contacting Richard Horne, who was one
  161. of the people responsible for creating the library, to no avail. 
  162. If anyone out there in reader-land knows of a later version,
  163. please write me care of this magazine or send me Email at
  164. RandyWrite@aol.com.  Also, if you would like to have a copy of my
  165. 3DPlot program with X-Specs support along with the .fd and C
  166. header files discussed in this article, please let me know.  I'll
  167. get a disk out to you.  If anyone has written X-Specs
  168. applications and is willing to share them, please send me a disk. 
  169. I would be interested in seeing them.  In the mean time, all you
  170. Amiga programmers should pull out that compiler and get to work.
  171.